const path = require('path');
const RabbitMQ = require('./app/utils/rabbitmq');
const Judge = require('./app/utils/judge');
const OpenAI = require('./app/utils/openAi');
module.exports = async app => {
  // 加载所有的校验规则
  this.app = app;
  const directory = path.join(app.config.baseDir, './app/validate');
  app.loader.loadToApp(directory, 'validate');
  this.app.rabbitmq = new RabbitMQ();
  await this.app.rabbitmq.connect();
  const errorHandle = require('./app/middleware/error_handler')({}, this.app);
  this.app.use(errorHandle);
  const judge = new Judge(this.app);
  judge.startJudge();
  this.app.openai = new OpenAI();
};

